package com.sskj.uboex.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.StockCoinBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.uboex.http.HttpConfig;
import com.sskj.uboex.ui.activity.SelfChooseActivity;

import java.util.List;


public class SelfChooseActivityPresenter extends BasePresenter<SelfChooseActivity> {
    public void getData(String code, boolean isArea) {
        httpService.getProduct(isArea ? null : code)
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<StockCoinBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<StockCoinBean>>> response) {
                        HttpData<List<StockCoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateCoin(httpData.getData());
                        }
                    }

                    @Override
                    public void onError(Response<HttpData<List<StockCoinBean>>> response) {
                        super.onError(response);
                    }
                });
    }
}
